<template>
	<div>
		<el-dialog :title="$t('action.add')" width="70%" class="icon-dialog" :visible.sync="show" @open="open" :before-close="closeForm" append-to-body>
			<el-form :size="size" ref="form" :model="form" :rules="rules" :label-width="$store.getters.device !== 'mobile'?'16%':'90px'">

<!--	 				 <el-row >-->
<!--					<el-col :span="24">-->
<!--						<el-form-item :label="$t('field.Receive_BillNo')" prop="BillNo">-->
<!--							<el-input v-model="form.BillNo" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Receive_BillNo')})">-->
<!--							</el-input>-->
<!--						</el-form-item>-->
<!--					</el-col>-->
<!--				 </el-row>-->
	 				 <el-row >
<!--					<el-col :span="24">-->
<!--						<el-form-item :label="$t('field.Receive_DATE')" prop="DATE">-->
<!--							<el-input v-model="form.DATE" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Receive_DATE')})">-->
<!--							</el-input>-->
<!--						</el-form-item>-->
<!--					</el-col>-->
				 </el-row>
<!--	 				 <el-row >-->
<!--					<el-col :span="24">-->
<!--						<el-form-item label="供应商编码" prop="PurDept">-->
<!--							<el-input v-model="form.SupplierNo" autoComplete="off" clearable  placeholder="请输入供应商编码">-->
<!--							</el-input>-->
<!--						</el-form-item>-->
<!--					</el-col>-->
<!--				 </el-row>-->
        <el-row >
          <el-col :span="24">
            <el-form-item label="供应商名称" prop="SupplierName">
              <el-input v-model="form.SupplierName" autoComplete="off" clearable  placeholder="请输入供应商名称">
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row >
          <el-col :span="24">
            <el-form-item label="物料编码" prop="MaterialNo">
              <el-input v-model="form.MaterialNo" autoComplete="off" clearable  placeholder="请输入物料编码">
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="24">
            <el-form-item label="物料名称" prop="MaterialName">
              <el-input v-model="form.MaterialName" autoComplete="off" clearable  placeholder="请输入物料名称">
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="24">
            <el-form-item label="规格" prop="Specification">
              <el-input v-model="form.Specification" autoComplete="off" clearable  placeholder="请输入物料规格">
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="24">
            <el-form-item label="单位" prop="Specification">
              <el-input v-model="form.UnitName" autoComplete="off" clearable  placeholder="请输入单位">
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="24">
            <el-form-item label="批号" prop="Lot">
              <el-input v-model="form.Lot" autoComplete="off" clearable  placeholder="请输入批号">
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row >
          <el-col :span="24">
            <el-form-item label="数量" prop="DeliveQty">
              <el-input v-model="form.DeliveQty" autoComplete="off" clearable  placeholder="请输入交货数量">
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Receive_IsWeight')" prop="IsWeight">
              <el-checkbox v-model="form.IsWeight">是否称重</el-checkbox>
						</el-form-item>
					</el-col>
				 </el-row>
				</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button :size="size" :loading="loading" type="primary" @click="submit" >
					<span v-if="!loading">{{$t('system.confirm')}}</span>
					<span v-else>{{$t('system.submitting')}}</span>
				</el-button>
				<el-button :size="size" @click="closeForm">{{$t('system.cancel')}}</el-button>
			</div>
		</el-dialog>
	</div>
</template>
<script>
import { add } from '@/api/app/receive'



export default {
	name:'receiveadd',
	components: {
	   	   
	},
	props: {
		show: {
			type: Boolean,
			default: false
		},
		size: {
			type: String,
			default: 'small'
		},
		querys:{
			type:Object,
		},
	},
	data(){
		return {
		    dialog:{
			},
			
			form: {
			   Fid:'',
			   BillNo:'',
			   DATE:'',
			   PurDept:'',
			   PurChaser:'',
			   OrgNumber:'',
			   OrgName:'',
			   IsWeight:'',
        Lot:'',
        UnitName:'',
         MaterialNo:'',
        MaterialName:'',
        Specification:'',
        SupplierNo:'',
        SupplierName:'',
        DeliveQty:'',//数量

			},
		    initial:{},   
			loading:false,
			rules: {
			}
		}
	},
	watch:{
		show(val){
			if(val){
			}
		}
	},
	methods: {
		open(){
		  if(this.querys){
		  }
		},
		submit(){
			this.$refs['form'].validate(valid => {
				if(valid) {
					this.loading = true
					add(this.form).then(res => {
						if(res.status == 200){
							this.$message({message: this.$t('system.success'), type: 'success'})
							this.$emit('refresh_list')
							this.closeForm()
						}
					}).catch(()=>{
						this.loading = false
					})
				}
			})
		},
		closeForm(){
			this.$emit('update:show', false)
			this.loading = false
			if (this.$refs['form']!==undefined) {
				this.$refs['form'].resetFields()
			}
		},
	}
}
</script>
<style scoped lang="scss">
@import '@/assets/scss/common.scss';
</style>
